#include "xRender.h"



void xRender::resize(GLsizei w, GLsizei h)
{
	GLfloat aspect;

	if (h == 0)
		h=1;

	this->windowW = w;
	this->windowH = h;

	glViewport(0, 0, w, h);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	aspect = (GLfloat)w / (GLfloat)h;

	if (w <= h)
		glOrtho(-100.0, 100.0, -100 / aspect, 100.0 / aspect, 1.0, -1.0);
	else
		glOrtho(-100.0*aspect, 100*aspect, -100, 100, 1, -1);


	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();



}

void xRender::setupRC()
{
	// Clear colour
	glClearColor(0.0f, 0.2f, 0.5f, 1.0f);
}

void xRender::draw(void)
{
	glClear(GL_COLOR_BUFFER_BIT);


	// Draw here
	glRectf(this->x,this->y,this->x+15,this->y+15);
	
	// End draw

}

void xRender::drawText(int x, int y, char *text)
{
	char *c;
	glRasterPos2i(x,y);
	for (c=text; *c != '\0'; c++)
	{
		glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12,*c);
	}
}